package org.lakeside.outreach.client;

import java.util.List;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.VerticalPanel;

public class EventListPanel extends Composite {

	private VerticalPanel outer = new VerticalPanel();
	private FlexTable table = new FlexTable();
	private int numRows = 0;
	
	public EventListPanel() {
		// initialize table
		table.setText(0, 0, "Date");
		table.setText(0, 1, "Volunteer Hours");
		table.setText(0, 2, "Staff Hours");
		table.setText(0, 1, "Cost");
		
		outer.add(table);
		
		initWidget(outer);
	}
	
	public void setEvents(List<Event> events) {
		for(Event event: events) {
			setEvent(event);
		}
	}
	
	public void setEvent(Event event) {
		numRows++;
		table.setText(numRows, 0, event.getDate().toString());
		table.setText(numRows, 1, Float.toString(event.getVolunteerHours()));
		table.setText(numRows, 2, Float.toString(event.getStaffHours()));
		table.setText(numRows, 3, Double.toString(event.getCost()));
	}
}
